package com.example.simple_file_chooser.test;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.Nullable;

import com.example.simple_file_chooser.FunCallback;
import com.example.simple_file_chooser.PathUtil;
import com.example.simple_file_chooser.R;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_explorer);
        findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                //通过intent发送数据
                intent.setAction("android.intent.action.VIEW");
                //创建一个链接  链接.语法解析
                Uri content_url = Uri.parse("https://pgyer.com/findroid");
                //通过intent接受
                intent.setData(content_url);
                //开始于当前intent
                startActivity(intent);
            }
        });
//        String options = "{\"xml\":{\"id_right_choose\":\"ok\",\"id_left_display\":\"name\",\"id_spec_choose\":\"ok\",\"id_click_cnt\":\"R.id.layout\",\"unselect\":\":invisible\",\"select\":\":visible\",\"cnt_layout\":\"com.aliang.auto.R.layout.auto_string_item_choosable_black\",\"select_default\":\"0\"},\"data\":[{\"name\":\"高德地图 (默认)\"},{\"name\":\"谷歌地图\"}]}";
//        JsonPopHandler.withCtx(this).pop(options);
        pathUtil.onCreate(findViewById(R.id.sdpath));
        pathUtil.setFunCallback(new FunCallback() {
            @Override
            public void onCallback(Object result, Object object) {
                super.onCallback(result, object);
                ((EditText)findViewById(R.id.edit)).setText(result.toString());
            }
        });
    }

    PathUtil pathUtil = new PathUtil();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        pathUtil.onDestroy();
    }
}
